﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Test.Model;
using System.Data;
using System.Data.SqlClient;
using Test.IDAL;
using Test.Common;

namespace Test.DAL
{
    public class ClassInfoDAL:baseDAL<ClassInfo>,IClassInfoDAL
    {
       
        public OperResult<List<ClassInfo>>  Select(string name="")
        {
           
           
            return Select(p=>p.Name.Contains(name));
        }

        public OperResult<int>  Update(ClassInfo info)
        {
            var data = Model.ClassInfoes.Find(info.Id);
            
            try
            {

               
                if (data != null)
                {
                   
                    data.Name = info.Name;
                    data.content = info.content;
                }
                return OperResult<int>.Success(Model.SaveChanges());
            }
            catch (Exception ex)
            {
                return OperResult<int>.Failed(ex.Message);

            }
        }
    }
}
